Generally, a nonvolatile memory such as a flash memory is configured to write data to another physical area or erase data, while leaving existing data. Thus, if data writing and erasing are repeated, a divided unwanted area remains, and a used area for storing data is kept divided. An operation to erase an unwanted area and collect a used area is called compaction or garbage collection. Garbage collection in a conventional semiconductor memory device is disclosed in Republished Jpn. PCT National Publication No. WO2004/077447, for example.
After data writing or invalidating, management data is updated, and a used ratio of flash memory is calculated. Necessity of garbage collection is determined according to the calculated used ratio, and garbage collection is performed if necessary. Garbage collection takes a relatively long time, and if user data is accessed during garbage collection, the access time becomes longer time than usual. This problem can be solved by making garbage collection at a different timing from accessing user data in a flash memory. For this purpose, the device disclosed in Republished Jpn. PCT National Publication No. WO2004/077447 provides a flash memory, which can inform an external unit of the timing to erase unnecessary data, like garbage collection. A used ratio calculator determines the state of a flag area, determines the state of a user area, calculates the invalid ratio of user area, and sends the calculated ratio to a controller. A controller receives the ratio, and outputs it to an external unit immediately after data writing or invalidating. A controller of a flash memory receives a write command, writes data in a specified user area, and writes a value indicating the validity of the data in a corresponding flag area. Then, the ratio calculator determines the state of a flag area, and calculates the invalid ratio of a user area. The controller receives the ratio calculated by the ratio calculator, and outputs it to a data bus to notify it to an external unit.
An operation delay caused by garbage collection raises other problems. To prepare for garbage collection, firmware has to periodically and uniquely request hardware to retrieve a block or an object of garbage collection.
Conventionally, access to a main memory is temporarily increased due to the retrieval, and a transfer bandwidth of a main memory is consumed. This interrupts an access to a main memory associated with transfer of user data between a flash memory and a main memory, and decreases an operation speed.
In the semiconductor memory device disclosed in Republished Jpn. PCT National Publication No. WO2004/077447, a flash memory chip memory cell stores table information called a “flag area” for determining the valid number of blocks in a chip. The table must be accessed (access to a flash memory) when retrieving a candidate for garbage collection. A flash memory chip itself determines a block for garbage collection, and garbage collection can be performed for each chip.
A conventional nonvolatile memory controller has another problem that the rate to access a main memory is decreased by retrieving a block as a candidate for compaction.